﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using WindowsFormsApplication5.settings;

namespace WindowsFormsApplication5.sheets
{
    public class DataWriter
    {
        public void writeData(string savepath, string hostname, Datablock dataBlock)
        {
            StreamWriter SW;
            SW = File.CreateText(savepath + "\\" + hostname + ".txt");

            // Grundkonfiguration
            SW.Write("" + dataBlock.router_config.toString());

            // Schnittstellen
            for (int i = 0; i < 4; i++)
            {
                if (dataBlock.port_config[i] != null)
                {
                    SW.Write(dataBlock.port_config[i].toString());
                }
            }

            // RIPv2
            SW.Write("" + dataBlock.rip_config.toString());

            // OSPF
            SW.Write("" + dataBlock.ospf_config.toString());

            // Routing
            foreach(Static_Routerconfig config in dataBlock.static_router_configurations)
            {
                if (config != null)
                {
                    SW.Write(config.toString());
                }
            }
            SW.WriteLine("!");           

            SW.Close();
            Console.WriteLine("File Created SucacessFully");
        }
    }
}

